From 65de04cdb8c1fcaffc956a776ac38bc7d9d15c1e Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Thu, 6 Jan 2000 01:08:10 +0000 Subject: [PATCH] Added scaling functions into gtk-doc framework. 2000-01-05 Owen Taylor * doc/Makefile.am doc/gdk-pixbuf-sections.txt doc/gdk-pixbuf.sgml doc/tmpl/scaling.sgml: Added scaling functions into gtk-doc framework. * gdk-pixbuf/gdk-pixbuf-scale.c: Documentation fixes. * gdk-pixbuf/testpixbuf-scale.c (expose_cb): Simplify a bit. * gdk-pixbuf/pixops/pixops.c (pixops_composite_color): Return immediately if scale_x or scale_y is 0. --- demos/testpixbuf-scale.c | 23 +-- docs/reference/gdk-pixbuf/Makefile.am | 3 +- docs/reference/gdk-pixbuf/gdk-pixbuf-decl.txt | 45 ++++- .../gdk-pixbuf/gdk-pixbuf-sections.txt | 9 + docs/reference/gdk-pixbuf/gdk-pixbuf.args | 8 +- docs/reference/gdk-pixbuf/gdk-pixbuf.sgml | 2 + docs/reference/gdk-pixbuf/tmpl/animation.sgml | 9 +- .../gdk-pixbuf/tmpl/from-drawables.sgml | 4 +- .../gdk-pixbuf/tmpl/gdk-pixbuf-unused.sgml | 45 +++++ .../gdk-pixbuf/tmpl/gnome-canvas-pixbuf.sgml | 51 ++---- docs/reference/gdk-pixbuf/tmpl/scaling.sgml | 162 ++++++++++++++++++ docs/reference/gdk-pixbuf/tmpl/util.sgml | 3 +- gdk-pixbuf/ChangeLog | 13 ++ gdk-pixbuf/gdk-pixbuf-scale.c | 24 +-- gdk-pixbuf/pixops/pixops.c | 9 + 15 files changed, 328 insertions(+), 82 deletions(-) create mode 100644 docs/reference/gdk-pixbuf/tmpl/scaling.sgml diff --git a/demos/testpixbuf-scale.c b/demos/testpixbuf-scale.c index da2e2b0ed6..2efafd6da9 100644 --- a/demos/testpixbuf-scale.c +++ b/demos/testpixbuf-scale.c @@ -34,22 +34,13 @@ expose_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) dest = gdk_pixbuf_new (ART_PIX_RGB, FALSE, 8, event->area.width, event->area.height); - if (pixbuf->art_pixbuf->has_alpha || overall_alpha != 255) - gdk_pixbuf_composite_color (pixbuf, dest, - 0, 0, event->area.width, event->area.height, - -event->area.x, -event->area.y, - (double) widget->allocation.width / pixbuf->art_pixbuf->width, - (double) widget->allocation.height / pixbuf->art_pixbuf->height, - filter_level, overall_alpha, - event->area.x, event->area.y, 16, 0xaaaaaa, 0x555555); - else - gdk_pixbuf_scale (pixbuf, dest, - 0, 0, event->area.width, event->area.height, - -event->area.x, -event->area.y, - (double) widget->allocation.width / pixbuf->art_pixbuf->width, - (double) widget->allocation.height / pixbuf->art_pixbuf->height, - filter_level); - + gdk_pixbuf_composite_color (pixbuf, dest, + 0, 0, event->area.width, event->area.height, + -event->area.x, -event->area.y, + (double) widget->allocation.width / pixbuf->art_pixbuf->width, + (double) widget->allocation.height / pixbuf->art_pixbuf->height, + filter_level, overall_alpha, + event->area.x, event->area.y, 16, 0xaaaaaa, 0x555555); gdk_pixbuf_render_to_drawable (dest, widget->window, widget->style->fg_gc[GTK_STATE_NORMAL], 0, 0, event->area.x, event->area.y, diff --git a/docs/reference/gdk-pixbuf/Makefile.am b/docs/reference/gdk-pixbuf/Makefile.am index 40d2a83956..b66ecede00 100644 --- a/docs/reference/gdk-pixbuf/Makefile.am +++ b/docs/reference/gdk-pixbuf/Makefile.am @@ -27,6 +27,7 @@ tmpl_sources = \ tmpl/gnome-canvas-pixbuf.sgml \ tmpl/refcounting.sgml \ tmpl/rendering.sgml \ + tmpl/scaling.sgml \ tmpl/util.sgml gdk_pixbuf_docdir = $(HTML_DIR) @@ -56,7 +57,7 @@ scan: -(cd $(srcdir) \ && env CFLAGS=$(CFLAGS) LDFLAGS=$(LDFLAGS) \ gtkdoc-scanobj --module=$(DOC_MODULE) \ - && gtkdoc-scan --module=$(DOC_MODULE) --source-dir=$(DOC_SOURCE_DIR) ) + && gtkdoc-scan --module=$(DOC_MODULE) --source-dir=$(DOC_SOURCE_DIR) --ignore-headers="pixops.h pixops-internal.h" ) templates: scan cd $(srcdir) && gtkdoc-mktmpl --module=$(DOC_MODULE) diff --git a/docs/reference/gdk-pixbuf/gdk-pixbuf-decl.txt b/docs/reference/gdk-pixbuf/gdk-pixbuf-decl.txt index be6b6adab4..884c3247b6 100644 --- a/docs/reference/gdk-pixbuf/gdk-pixbuf-decl.txt +++ b/docs/reference/gdk-pixbuf/gdk-pixbuf-decl.txt @@ -6,9 +6,23 @@ GdkPixbuf *pixbuf, gpointer user_data ModuleUpdatedNotifyFunc void -GdkPixbuf *pixbuf, gpointer user_data, +GdkPixbuf *pixbuf, guint x, guint y, - guint width, guint height + guint width, guint height, + gpointer user_data + + +ModuleFrameDoneNotifyFunc +void +GdkPixbuf *pixbuf, + gint frame, + gpointer user_data + + +ModuleAnimationDoneNotifyFunc +void +GdkPixbuf *pixbuf, + gpointer user_data GdkPixbufModule @@ -26,6 +40,8 @@ struct GdkPixbufModule { gpointer (* begin_load) (ModulePreparedNotifyFunc prepare_func, ModuleUpdatedNotifyFunc update_func, + ModuleFrameDoneNotifyFunc frame_done_func, + ModuleAnimationDoneNotifyFunc anim_done_func, gpointer user_data); void (* stop_load) (gpointer context); gboolean (* load_increment) (gpointer context, const guchar *buf, guint size); @@ -275,6 +291,31 @@ GdkPixbuf *pixbuf, GdkDrawable *drawable,int src_x, int src_y,int dest_x, int de GdkPixbuf *dest,GdkDrawable *src, GdkColormap *cmap,int src_x, int src_y,int dest_x, int dest_y,int width, int height +gdk_pixbuf_scale +void +GdkPixbuf *src,GdkPixbuf *dest,int dest_x,int dest_y,int dest_width,int dest_height,double offset_x,double offset_y,double scale_x,double scale_y,ArtFilterLevel filter_level + + +gdk_pixbuf_composite +void +GdkPixbuf *src,GdkPixbuf *dest,int dest_x,int dest_y,int dest_width,int dest_height,double offset_x,double offset_y,double scale_x,double scale_y,ArtFilterLevel filter_level,int overall_alpha + + +gdk_pixbuf_composite_color +void +GdkPixbuf *src,GdkPixbuf *dest,int dest_x,int dest_y,int dest_width,int dest_height,double offset_x,double offset_y,double scale_x,double scale_y,ArtFilterLevel filter_level,int overall_alpha,int check_x,int check_y,int check_size,art_u32 color1,art_u32 color2 + + +gdk_pixbuf_scale_simple +GdkPixbuf * +GdkPixbuf *src,int dest_width,int dest_height,ArtFilterLevel filter_level + + +gdk_pixbuf_composite_color_simple +GdkPixbuf * +GdkPixbuf *src,int dest_width,int dest_height,ArtFilterLevel filter_level,int overall_alpha,int check_size,art_u32 color1,art_u32 color2 + + gdk_pixbuf_animation_new_from_file GdkPixbufAnimation * const char *filename diff --git a/docs/reference/gdk-pixbuf/gdk-pixbuf-sections.txt b/docs/reference/gdk-pixbuf/gdk-pixbuf-sections.txt index bd2af95515..7de064ea74 100644 --- a/docs/reference/gdk-pixbuf/gdk-pixbuf-sections.txt +++ b/docs/reference/gdk-pixbuf/gdk-pixbuf-sections.txt @@ -60,6 +60,15 @@ gdk_pixbuf_animation_ref gdk_pixbuf_animation_unref +
+scaling +gdk_pixbuf_scale +gdk_pixbuf_composite +gdk_pixbuf_composite_color +gdk_pixbuf_scale_simple +gdk_pixbuf_composite_color_simple +
+
gdk-pixbuf-loader GDK_PIXBUF_LOADER diff --git a/docs/reference/gdk-pixbuf/gdk-pixbuf.args b/docs/reference/gdk-pixbuf/gdk-pixbuf.args index 8813bd7b35..b212136dca 100644 --- a/docs/reference/gdk-pixbuf/gdk-pixbuf.args +++ b/docs/reference/gdk-pixbuf/gdk-pixbuf.args @@ -17,7 +17,7 @@ -GnomeCanvasPixbuf::width_in_pixels +GnomeCanvasPixbuf::width_pixels gboolean rw @@ -35,7 +35,7 @@ -GnomeCanvasPixbuf::height_in_pixels +GnomeCanvasPixbuf::height_pixels gboolean rw @@ -53,7 +53,7 @@ -GnomeCanvasPixbuf::x_in_pixels +GnomeCanvasPixbuf::x_pixels gboolean rw @@ -71,7 +71,7 @@ -GnomeCanvasPixbuf::y_in_pixels +GnomeCanvasPixbuf::y_pixels gboolean rw diff --git a/docs/reference/gdk-pixbuf/gdk-pixbuf.sgml b/docs/reference/gdk-pixbuf/gdk-pixbuf.sgml index b95e72f7fe..410a2cc3e7 100644 --- a/docs/reference/gdk-pixbuf/gdk-pixbuf.sgml +++ b/docs/reference/gdk-pixbuf/gdk-pixbuf.sgml @@ -4,6 +4,7 @@ + @@ -49,6 +50,7 @@ &gdk-pixbuf-file-loading; &gdk-pixbuf-creating; &gdk-pixbuf-rendering; + &gdk-pixbuf-scaling; &gdk-pixbuf-from-drawables; &gdk-pixbuf-util; &gdk-pixbuf-animation; diff --git a/docs/reference/gdk-pixbuf/tmpl/animation.sgml b/docs/reference/gdk-pixbuf/tmpl/animation.sgml index f578a841e7..ff23a56321 100644 --- a/docs/reference/gdk-pixbuf/tmpl/animation.sgml +++ b/docs/reference/gdk-pixbuf/tmpl/animation.sgml @@ -13,13 +13,11 @@ Animations as multi-frame structures. about the frame's overlay mode and duration. - #GdkPixbufLoader - Each animation frame can have several things happen to it when the @@ -82,12 +80,11 @@ Animations as multi-frame structures. -@animation: - - - + + diff --git a/docs/reference/gdk-pixbuf/tmpl/from-drawables.sgml b/docs/reference/gdk-pixbuf/tmpl/from-drawables.sgml index 3415bcb123..252d57bfa4 100644 --- a/docs/reference/gdk-pixbuf/tmpl/from-drawables.sgml +++ b/docs/reference/gdk-pixbuf/tmpl/from-drawables.sgml @@ -32,9 +32,7 @@ Getting parts of a drawable's image data into a pixbuf. @dest_y: @width: @height: -@Returns: - - + + If this argument is %TRUE, then the width of the pixbuf will be + considered to be in pixels, that is, it will not be visually + scaled even if the item's affine transformation changes. If this + is %FALSE, then the width of the pixbuf will be considered to be + in canvas units, and so will be scaled normally by affine + transformations. The default is %FALSE. + + + @@ -15,6 +26,14 @@ + + + Works in the same way as the width_in_pixels + argument. The default is %FALSE. + + + @@ -29,6 +48,21 @@ @stop_load: @load_increment: + + + Works in the same way as the x_in_pixels + argument. The default is %FALSE. + + + + + @@ -68,3 +102,14 @@ gdk-pixbuf-io @size: @Returns: + + + If this argument is %TRUE, the pixbuf's translation with respect + to its logical origin in item-relative coordinates will be in + pixels, that is, the visible offset will not change even if the + item's affine transformation changes. If it is %FALSE, the + pixbuf's translation will be taken to be in canvas units, and thus + will change along with the item's affine transformation. + + + diff --git a/docs/reference/gdk-pixbuf/tmpl/gnome-canvas-pixbuf.sgml b/docs/reference/gdk-pixbuf/tmpl/gnome-canvas-pixbuf.sgml index fd5d97e5bf..cd2116528b 100644 --- a/docs/reference/gdk-pixbuf/tmpl/gnome-canvas-pixbuf.sgml +++ b/docs/reference/gdk-pixbuf/tmpl/gnome-canvas-pixbuf.sgml @@ -234,15 +234,10 @@ Canvas item to display #GdkPixbuf images. used instead. This argument is %FALSE by default. - - - If this argument is %TRUE, then the width of the pixbuf will be - considered to be in pixels, that is, it will not be visually - scaled even if the item's affine transformation changes. If this - is %FALSE, then the width of the pixbuf will be considered to be - in canvas units, and so will be scaled normally by affine - transformations. The default is %FALSE. - + + + + @@ -263,12 +258,10 @@ Canvas item to display #GdkPixbuf images. The default is %FALSE. - - - Works in the same way as the width_in_pixels - argument. The default is %FALSE. - + + + + @@ -287,15 +280,10 @@ Canvas item to display #GdkPixbuf images. coordinates. - - - If this argument is %TRUE, the pixbuf's translation with respect - to its logical origin in item-relative coordinates will be in - pixels, that is, the visible offset will not change even if the - item's affine transformation changes. If it is %FALSE, the - pixbuf's translation will be taken to be in canvas units, and thus - will change along with the item's affine transformation. - + + + + @@ -314,17 +302,8 @@ Canvas item to display #GdkPixbuf images. default is %FALSE. - - - Works in the same way as the x_in_pixels - argument. The default is %FALSE. - + + - + diff --git a/docs/reference/gdk-pixbuf/tmpl/scaling.sgml b/docs/reference/gdk-pixbuf/tmpl/scaling.sgml new file mode 100644 index 0000000000..153a5cf431 --- /dev/null +++ b/docs/reference/gdk-pixbuf/tmpl/scaling.sgml @@ -0,0 +1,162 @@ + +Scaling + + +Scaling pixbufs and scaling and compositing pixbufs + + + +gdk-pixbuf contains functions to scale pixbufs, to scale pixbufs and +composite against an existing image, and to scale pixbufs and +composite against a solid color or checkerboard. (Compositing a +checkerboard is a common way to show an image with an alpha-channel in +image-viewing and editing software.) + + +Since the full-featured functions (gdk_pixbuf_scale(), +gdk_pixbuf_composite(), and gdk_pixbuf_composite_color()) are +rather complex to use and have many arguments, two simple +convenience functions are provided, gdk_pixbuf_scale_simple() +and gdk_pixbuf_composite_color_simple() which create a +new pixbuf of a given size, scale an original image to fit, +and then return the new pixmap. + + + +The following example demonstrates handling an expose event by +rendering the appropriate area of a source image (which is scaled to +fit the widget) onto the widget's window. The source image is +rendered against a checkerboard, which provides a visual +representation of the alpha channel if the image has one. If the image +doesn't have an alpha channel, calling gdk_pixbuf_composite_color() +function has exactly the same effect as calling gdk_pixbuf_scale(). + + + +gboolean +expose_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) +{ + GdkPixbuf *dest; + + gdk_window_set_back_pixmap (widget->window, NULL, FALSE); + + dest = gdk_pixbuf_new (ART_PIX_RGB, FALSE, 8, event->area.width, event->area.height); + + gdk_pixbuf_composite_color (pixbuf, dest, + 0, 0, event->area.width, event->area.height, + -event->area.x, -event->area.y, + (double) widget->allocation.width / pixbuf->art_pixbuf->width, + (double) widget->allocation.height / pixbuf->art_pixbuf->height, + filter_level, 255, + event->area.x, event->area.y, 16, 0xaaaaaa, 0x555555); + + gdk_pixbuf_render_to_drawable (dest, widget->window, widget->style->fg_gc[GTK_STATE_NORMAL], + 0, 0, event->area.x, event->area.y, + event->area.width, event->area.height, + GDK_RGB_DITHER_NORMAL, event->area.x, event->area.y); + + gdk_pixbuf_unref (dest); + + return TRUE; +} + + + + + + + + + + + + +@src: +@dest: +@dest_x: +@dest_y: +@dest_width: +@dest_height: +@offset_x: +@offset_y: +@scale_x: +@scale_y: +@filter_level: + + + + + + + +@src: +@dest: +@dest_x: +@dest_y: +@dest_width: +@dest_height: +@offset_x: +@offset_y: +@scale_x: +@scale_y: +@filter_level: +@overall_alpha: + + + + + + + +@src: +@dest: +@dest_x: +@dest_y: +@dest_width: +@dest_height: +@offset_x: +@offset_y: +@scale_x: +@scale_y: +@filter_level: +@overall_alpha: +@check_x: +@check_y: +@check_size: +@color1: +@color2: + + + + + + + +@src: +@dest_width: +@dest_height: +@filter_level: +@Returns: + + + + + + + +@src: +@dest_width: +@dest_height: +@filter_level: +@overall_alpha: +@check_size: +@color1: +@color2: +@Returns: + + \ No newline at end of file diff --git a/docs/reference/gdk-pixbuf/tmpl/util.sgml b/docs/reference/gdk-pixbuf/tmpl/util.sgml index 3509f76681..f84edb50e0 100644 --- a/docs/reference/gdk-pixbuf/tmpl/util.sgml +++ b/docs/reference/gdk-pixbuf/tmpl/util.sgml @@ -27,8 +27,7 @@ Utility and miscellaneous convenience functions. @r: @g: @b: -@Returns: -